package com.jianguo.web.controller.order;

import java.util.Arrays;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianguo.common.annotation.Log;
import com.jianguo.common.core.controller.BaseController;
import com.jianguo.common.core.domain.AjaxResult;
import com.jianguo.common.enums.BusinessType;
import com.jianguo.order.domain.PzGroupMsg;
import com.jianguo.order.service.IPzGroupMsgService;
import com.jianguo.common.utils.poi.ExcelUtil;
import com.jianguo.common.core.page.TableDataInfo;

/**
 * 群组消息Controller
 *
 * @author xjj
 * @date 2024-04-23
 */
@RestController
@RequestMapping("/order/msg")
public class PzGroupMsgController extends BaseController
{
    @Autowired
    private IPzGroupMsgService pzGroupMsgService;

    /**
     * 查询群组消息列表
     */
    @PreAuthorize("@ss.hasPermi('order:msg:list')")
    @GetMapping("/list")
    public TableDataInfo list(PzGroupMsg pzGroupMsg)
    {
        startPage();
        List<PzGroupMsg> list = pzGroupMsgService.list();
        return getDataTable(list);
    }

    /**
     * 导出群组消息列表
     */
    @PreAuthorize("@ss.hasPermi('order:msg:export')")
    @Log(title = "群组消息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PzGroupMsg pzGroupMsg)
    {
        List<PzGroupMsg> list = pzGroupMsgService.selectPzGroupMsgList(pzGroupMsg);
        ExcelUtil<PzGroupMsg> util = new ExcelUtil<PzGroupMsg>(PzGroupMsg.class);
        util.exportExcel(response, list, "群组消息数据");
    }

    /**
     * 获取群组消息详细信息
     */
    @PreAuthorize("@ss.hasPermi('order:msg:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(pzGroupMsgService.getById(id));
    }

    /**
     * 新增群组消息
     */
    @PreAuthorize("@ss.hasPermi('order:msg:add')")
    @Log(title = "群组消息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PzGroupMsg pzGroupMsg) {
        return toAjax(pzGroupMsgService.save(pzGroupMsg));
    }

    /**
     * 修改群组消息
     */
    @PreAuthorize("@ss.hasPermi('order:msg:edit')")
    @Log(title = "群组消息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PzGroupMsg pzGroupMsg) {
        return toAjax(pzGroupMsgService.updateById(pzGroupMsg));
    }

    /**
     * 删除群组消息
     */
    @PreAuthorize("@ss.hasPermi('order:msg:remove')")
    @Log(title = "群组消息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(pzGroupMsgService.removeByIds(Arrays.asList(ids)));
    }
}
